package com.example.myapplication;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class PeopleAdapter extends ArrayAdapter<People> {
    public PeopleAdapter(@NonNull Context context , int resource, @NonNull List<People> objects)
    {
        super(context,resource,objects);
    }

    @NonNull
    @Override
    public View getView(int position , @Nullable View convertView, @NonNull ViewGroup parent)
    {
        People people = getItem(position);

        View view = LayoutInflater.from(getContext()).inflate(R.layout.meitem,parent,false);

        ImageView peopleimage = view.findViewById(R.id.people_image);
        TextView peoplename = view.findViewById(R.id.people_name);

        peopleimage.setImageResource(people.getImageID());
        peoplename.setText(people.getName());
        return view;
    }
}
